const koa = require("koa");
const app = new koa();
const koaBody = require("koa-body");
const router = require("koa-router")();
const cors = require("koa2-cors");
router.post("/login", async ctx => {
    /* username=cheng  pass=123456 */
    console.log(ctx.request.body);
    var { username, pass } = ctx.request.body;
    if (username == "z" && pass == "1") {
        ctx.body = {
            code: 200,
            msg: "登录成功"
        }
    } else {
        ctx.body = {
            code: 400,
            msg: "登录失败,用户名或密码错误"
        }
    }
})
app.use(cors());
app.use(koaBody());
app.use(router.routes());
app.listen(8000);